﻿using System;
using System.Data;

namespace DAL
{
    public static class DalCustomerCare
    {
        private static readonly clsConnect Cls = new clsConnect();
        #region[Get-Data]
        public static DataTable GetCustomerCare(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@KEYWORDS", keywords);
            return Cls.GetData("sp_CustomerCare_Get");
        }
        public static DataTable GetCustomerCareEdit(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID", id);
            return Cls.GetData("sp_CustomerCare_Get_Edit");
        }
        public static DataTable GetCustomerFillter(string DateBegin,string DateEnd)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@DateBegin", DateBegin);
            Cls.AddParameter("@EndBegin", DateEnd);
            return Cls.GetData("sp_CustomerCare_FillterDate");
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool Insert(EtCustomerCare obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Code", obj.Code);
            Cls.AddParameter("@ID_Form", obj.ID_Form);
            Cls.AddParameter("@Subjects", obj.Subjects);
            Cls.AddParameter("@Content", obj.Content);
            Cls.AddParameter("@DateBegin", obj.DateBegin);
            Cls.AddParameter("@DateEnd", obj.DateEnd);
            Cls.AddParameter("@IsActive", obj.IsActive);
            Cls.AddParameter("@Users_Id", obj.Users_Id);
            return Cls.ExecuteNonQuery("sp_CustomerCare_Insert");
        }
        public static bool Update(EtCustomerCare obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID", obj.ID);
            Cls.AddParameter("@Code", obj.Code);
            Cls.AddParameter("@ID_Form", obj.ID_Form);
            Cls.AddParameter("@Subjects", obj.Subjects);
            Cls.AddParameter("@Content", obj.Content);
            Cls.AddParameter("@DateBegin", obj.DateBegin);
            Cls.AddParameter("@DateEnd", obj.DateEnd);
            Cls.AddParameter("@IsActive", obj.IsActive);
            return Cls.ExecuteNonQuery("sp_CustomerCare_Update");
        }
        public static bool Delete(EtCustomerCare obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID", obj.ID);
            return Cls.ExecuteNonQuery("sp_CustomerCare_Delete");
        }
        #endregion
    }
    public class EtCustomerCare
    {
        public int ID { get; set; }
        public string Code { get; set; }
        public int ? ID_Form { get; set; }
        public string Subjects { get; set; }
        public string Content { get; set; }
        public DateTime DateBegin { get; set; }
        public DateTime DateEnd { get; set; }
        public bool IsActive { get; set; }
        public int Users_Id { get; set; }
    }
}